﻿package app.view.components.guiDima.slideShowD
{
	import flash.display.Shape;
	import flash.display.Sprite;
	import gs.TweenLite;
	
	/**
	 * Прелоадер
	 * @author www
	 */
	public class Preloader extends Sprite
	{
		private var __w:Number;
		private var __h:Number=2;
		private var _bgd:Shape;
		private static const COLOR:uint = 0xA2A3A5;
		private var _progress:Number;
		
		public function Preloader(w:Number) 
		{
			__w = w;
			
			init();
		}
		
		private function init():void
		{
			graphics.beginFill(0xff0000,0);
			graphics.drawRect(0, 0, __w, __h);
			graphics.endFill();
			
			_bgd = new Shape();
			_bgd.graphics.beginFill(COLOR);
			_bgd.graphics.drawRect(0, 0, __w, __h);
			_bgd.graphics.endFill();
			_bgd.scaleX = 0;
			addChild(_bgd);
			
			
		}
		
		public function destroy():void
		{
			removeChild(_bgd);
		}
		
		public function resetProgress():void
		{
			_bgd.scaleX = 0;
		}
		
		public function get progress():Number { return _progress; }
		
		public function set progress(value:Number):void 
		{
			_progress = value;
			
			////trace('pr',pr);
			TweenLite.to(_bgd, 0.5, { scaleX: (_progress / 100) ,ease:'none'} );
		}
		
	}

}